<template>
  <page-header class="my-15px" :count="count" :title="title" :menuId="menuId" is-small/>
  <div class="page-content-screen">
    <div class="screen">
      <vc-filter :menus="screen"/>
      <el-checkbox v-model="queryData.overproof">仅显示超标数据</el-checkbox>
    </div>
    <div class="total">共计 <span style="color: #FF5959;">{{ totalNum}}</span> 条</div>
  </div>
  <div class="page-content-table">
    <vc-table
      :loading="loading"
      :tableData="tableData"
      :columns="columns"
      :total="totalNum"
      :pageSize="PAGE_SIZE"
      :pageNum="queryData.pageNum"
      :maxHeight="800"
      @page-change="handleCurrentChange"
      @sort-change="sortChange"
    />
  </div>
</template>

<script lang="ts" setup>
import PageHeader from '../../../../components/page-header.vue';
import {getMonitoring} from "@/views/modules/enterprise/apis";
import {useTable} from './useTable';
import {useScreen} from './useScreen';
import {usePage} from '@/use/usePage';
import { useF9Context } from '../../../../use/use-context';
interface Props {
  /** 标题名称 */
  title: string;
  /** 标题 id */
  menuId: string;
  /** 数值 */
  count: number | null;
}
const { companyId } = useF9Context();
const route = useRoute();
const {PAGE_SIZE, screen, queryData} = useScreen(companyId, 2);
const {title, menuId, count} = defineProps<Props>();
queryData.type = 2;
queryData.id = companyId;
queryData.overproof = false;
const {data, loading, run} = useRequest(getMonitoring, {
  defaultParams: [{...queryData}],
  onSuccess: (data) => {
    tableData.value = data.monitorItems;
    totalNum.value = data.totalMonitorCount;
  }
});
const {columns} = useTable();
const {
  tableData,
  totalNum,
  searchTxt,
  handlerInput,
  handleCurrentChange,
  sortChange
} = usePage(queryData, run);

</script>

<style scoped lang="scss">
.page-content-screen {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(0, 0, 0, 0.85);

  .screen {
    display: flex;
    align-items: center;
    gap: 40px;
  }

  .total {
    font-size: 12px;
    line-height: 24px;
  }
}
</style>
